package com.hongyue.dey02;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Demo {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.out.println("now = " + now);
        LocalDateTime of = LocalDateTime.of(2020, 10, 1, 8, 30, 40);
        System.out.println("of = " + of);
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String format = now.format(dtf);
        System.out.println("format = " + format);
        String format1 = of.format(dtf);
        System.out.println("format1 = " + format1);
        String a = "2020-09-23 14:31:50";
        LocalDateTime parse = LocalDateTime.parse(a, dtf);
        System.out.println("parse = " + parse);
        String format2 = parse.format(dtf);
        System.out.println("format2 = " + format2);
    }
}
